﻿@model VOD.Models.Comment

<div class="addcomment">
    <h3>想说点什么？<a id="comm"></a>
        @*@if(!Request.IsAuthenticated){
        <a href="javascript:;" class="btnLogin">点击登录</a>
        }*@
    </h3>
    @using (Ajax.BeginForm("Create","Comment",new AjaxOptions{ UpdateTargetId="Comments", HttpMethod="POST", OnComplete="clearTextArea"})){
        @*<p>按Ctrl+Enter快捷发布</p>*@
        @Html.Hidden("VideoID",Model.VideoID)
        @Html.Hidden("ParentID")
        <div class="submit">
            @Html.TextAreaFor(model => model.CommentContent, new { @class="txtContent"})
            <a>
                <input type="button" class="btnPost" />
            </a>
        </div>
    }
</div>
@Content.Script("jquery.min.js", Url)
<script type="text/javascript">
    var clearTextArea = function () {
        $("#CommentContent").val("");
    };
    $(function(){
        $(".btnPost").bind("click", function () {
            if ($("#CommentContent").val() == "") {
                alert("请输入内容！");
            }
            else {
                $.ajax({
                    url:"@Url.Content("~/Comment/Create/")",
                    data:"videoID="+$("#VideoID").val()+"&ParentID="+$("#ParentID").val()+"&commentContent="+$("#CommentContent").val(),
                    type:"POST",
                    success:function(){
                        var url1="@Url.Content("~/Comment/Index/")@Model.VideoID";
                        $("#Comments").load(url1);
                    }
                });
            }
        });
    });
    
</script>